package org.example.config;

import org.example.controller.interceptor.ProjectInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@EnableWebMvc
@ComponentScan({"org.example.controller","org.example.config"})
public class springMvcConfig implements WebMvcConfigurer {
    @Autowired
    private org.example.controller.interceptor.ProjectInterceptor ProjectInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new ProjectInterceptor())
                .addPathPatterns("/food/**")  // 拦截/food路径下的所有请求
                .addPathPatterns("/**");       // 或者拦截所有请求
    }
}
